package com.suep.system.service.impl;

import com.suep.system.service.IQQEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class QQEmailServiceImpl implements IQQEmailService {

    @Autowired
    private JavaMailSender mailSender;

    @Value("${spring.mail.username}")
    private String sender;

    /**
     * 发送简单文本邮件
     * @param to 收件人邮箱
     * @param subject 邮件主题
     * @param content 邮件内容
     */
    public void sendSimpleMail(String to, String subject, String content) {
        // 创建简单邮件消息对象
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(sender); // 发件人（需与配置中的 username 一致）
        message.setTo(to);                   // 收件人
        message.setSubject(subject);         // 邮件主题
        message.setText(content);            // 邮件内容

        // 发送邮件
        mailSender.send(message);
    }
}
